﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.ComponentModel;

namespace Locations
{
    public partial class tblLocation
    {
        public tblLocation() : base()
        {
            AddressReference.AssociationChanged += new System.ComponentModel.CollectionChangeEventHandler(
                (object o, CollectionChangeEventArgs e) => AssociationChanged("Address", e));
        }

        void AssociationChanged(string association, System.ComponentModel.CollectionChangeEventArgs e)
        {
            if (e.Action == System.ComponentModel.CollectionChangeAction.Remove)
                OnPropertyChanging(association);
            else
                OnPropertyChanged(association);
        }
    }

    public partial class tblAddress
    {
        public tblAddress()
            : base()
        {
            // Set the default value for the country.
            CountryReference.EntityKey = new EntityKey("SalesManagerEntities.codeCountry", "CountryID", 468);

            CountryReference.AssociationChanged += new System.ComponentModel.CollectionChangeEventHandler(
                (object o, CollectionChangeEventArgs e) => AssociationChanged("Country", e));
        }

        void AssociationChanged(string association, System.ComponentModel.CollectionChangeEventArgs e)
        {
            if (e.Action == System.ComponentModel.CollectionChangeAction.Remove)
                OnPropertyChanging(association);
            else
                OnPropertyChanged(association);
        }
    }

    public partial class tblLocationPerson
    {
        public tblLocationPerson()
            : base()
        {
            LocationReference.AssociationChanged += new System.ComponentModel.CollectionChangeEventHandler(
                (object o, CollectionChangeEventArgs e) => AssociationChanged("Location", e));
            PersonReference.AssociationChanged += new System.ComponentModel.CollectionChangeEventHandler(
                (object o, CollectionChangeEventArgs e) => AssociationChanged("Person", e));
        }

        void AssociationChanged(string association, System.ComponentModel.CollectionChangeEventArgs e)
        {
            if (e.Action == System.ComponentModel.CollectionChangeAction.Remove)
                OnPropertyChanging(association);
            else
                OnPropertyChanged(association);
        }
    }
}
